package com.ruoyi.control.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; //添加
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.control.mapper.JingxiaHistoryMapper;
import com.ruoyi.control.domain.JingxiaHistory;
import com.ruoyi.control.service.IJingxiaHistoryService;

/**
 * 井下水文历史数据Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-11-08
 */
@Service
public class JingxiaHistoryServiceImpl extends ServiceImpl<JingxiaHistoryMapper, JingxiaHistory> implements IJingxiaHistoryService //修改
{
    @Autowired
    private JingxiaHistoryMapper jingxiaHistoryMapper;

    /**
     * 查询井下水文历史数据
     * 
     * @param id 井下水文历史数据主键
     * @return 井下水文历史数据
     */
    @Override
    public JingxiaHistory selectJingxiaHistoryById(String id)
    {
        return jingxiaHistoryMapper.selectJingxiaHistoryById(id);
    }

    /**
     * 查询井下水文历史数据列表
     * 
     * @param jingxiaHistory 井下水文历史数据
     * @return 井下水文历史数据
     */
    @Override
    public List<JingxiaHistory> selectJingxiaHistoryList(JingxiaHistory jingxiaHistory)
    {
        return jingxiaHistoryMapper.selectJingxiaHistoryList(jingxiaHistory);
    }

    /**
     * 查询井下水文历史数据近三天平均数据
     *
     * @return 测点历史信息数据集合
     */
    @Override
    public String selectJingxiaHistoryListThreeAvg(String MeasureName, String Address) {
        return jingxiaHistoryMapper.selectJingxiaHistoryListThreeAvg(MeasureName,Address);
    }

    /**
     * 查询井下水文历史数据近一天平均数据
     *
     * @return 测点历史信息数据集合
     */
    @Override
    public String selectJingxiaHistoryListOneAvg(String MeasureName, String Address) {
        return jingxiaHistoryMapper.selectJingxiaHistoryListOneAvg(MeasureName,Address);
    }

    /**
     * 查询井下水文历史数据自定义时间平均数据
     *
     * @return 测点历史信息数据集合
     */
    @Override
    public String selectJingxiaHistoryListCustomTime(String MeasureName, String Address, String customTime) {
        return jingxiaHistoryMapper.selectJingxiaHistoryListCustomTime(MeasureName,Address,customTime);
    }

    /**
     * 新增井下水文历史数据
     * 
     * @param jingxiaHistory 井下水文历史数据
     * @return 结果
     */
    @Override
    public int insertJingxiaHistory(JingxiaHistory jingxiaHistory)
    {
        return jingxiaHistoryMapper.insertJingxiaHistory(jingxiaHistory);
    }

    /**
     * 修改井下水文历史数据
     * 
     * @param jingxiaHistory 井下水文历史数据
     * @return 结果
     */
    @Override
    public int updateJingxiaHistory(JingxiaHistory jingxiaHistory)
    {
        return jingxiaHistoryMapper.updateJingxiaHistory(jingxiaHistory);
    }

    /**
     * 批量删除井下水文历史数据
     * 
     * @param ids 需要删除的井下水文历史数据主键
     * @return 结果
     */
    @Override
    public int deleteJingxiaHistoryByIds(String[] ids)
    {
        return jingxiaHistoryMapper.deleteJingxiaHistoryByIds(ids);
    }

    /**
     * 删除井下水文历史数据信息
     * 
     * @param id 井下水文历史数据主键
     * @return 结果
     */
    @Override
    public int deleteJingxiaHistoryById(String id)
    {
        return jingxiaHistoryMapper.deleteJingxiaHistoryById(id);
    }

    @Override
    public int getSsll() {
        JingxiaHistory jingxiaHistory = new JingxiaHistory();
        jingxiaHistory.setCode("520111001-A103");
        List<JingxiaHistory> jingxiaHistories = jingxiaHistoryMapper.selectJingxiaHistoryList(jingxiaHistory);
        int count = 0;
        for (JingxiaHistory history : jingxiaHistories) {
            if (history.getValue() > 0.5){
                count ++;
            }
        }
        return count;
    }

    @Override
    public List<JingxiaHistory> getInstantFlow() {
        List<JingxiaHistory> jingxiaHistoryList = jingxiaHistoryMapper.getInstantFlow();
        return jingxiaHistoryList;
    }

    @Override
    public List<JingxiaHistory> getChInstantFlow() {
        return jingxiaHistoryMapper.getChInstantFlow();
    }
}
